$(function() {

   if(!window.ActiveXObject){
        $("#footht").css("height","20px");
        $(".signshow").css("padding-left","10px");
       
    }else{
        $(".signshow").css("padding-left","20px");
    }
   initZYbg();
   initType();
   $(window).resize(function() {
			    initZYbg();
			   });
});
function initZYbg(){ 
     if(document.body.clientWidth<957){
	        $("#mainleft").width(0);
	        $("#mainright").width(0);
	        $("#mainleft").css("display","none");
		    $("#mainright").css("display","none");
		    $("#pager").css("left","0px");
        }else{
	       if(!window.ActiveXObject){
		        var wid=($(document).width()-953)/2;
		        $("#mainleft").width(wid);
		        $("#mainright").width(wid);
		        $("#mainleft").css("display","block");
		        $("#mainright").css("display","block");
		         $("#pager").css("left",wid+"px");
		    }else{
		        var wid=($(document).width()-974)/2;
		        if(wid>0){
		        	$("#mainleft").width(wid);
			        $("#mainright").width(wid);
			        $("#mainleft").css("display","block");
			        $("#mainright").css("display","block");
			        $("#pager").css("left",wid+"px");
		        }
		    }
        }
}
function initType(){
	if(type==1){
		ChengeNav("nva1");
	}else if(type==2){
		ChengeNav("nva2");
	}else if(type==3){
		ChengeNav("nva3");
	}
}
//点击切换国省市
function ChengeNav(obj){
	  $("#"+obj).removeClass("button").addClass("default");
	  if(obj=="nva1"){
		  $("#nva1").css("background","url(img/qt/guo.jpg)");
		  $("#nva2").css("background","url(img/qt/sheng1.jpg)");
		  $("#nva3").css("background","url(img/qt/shi1.jpg)");
		  $("#nva2").removeClass("default").addClass("button");
		  $("#nva3").removeClass("default").addClass("button");
		  $("#guo").css("display","");
		  $("#sheng").css("display","none");
		  $("#shi").css("display","none");
		  type=1;
		  initData();
	  }else if(obj=="nva2"){
		  $("#nva1").css("background","url(img/qt/guo1.jpg)");
		  $("#nva2").css("background","url(img/qt/sheng.jpg)");
		  $("#nva3").css("background","url(img/qt/shi1.jpg)");
		  $("#nva1").removeClass("default").addClass("button");
		  $("#nva3").removeClass("default").addClass("button");
		  $("#guo").css("display","none");
		  $("#sheng").css("display","");
		  $("#shi").css("display","none");
		  type=2;
		  initData();
	  }else if(obj=="nva3"){
		  $("#nva1").css("background","url(img/qt/guo1.jpg)");
		  $("#nva2").css("background","url(img/qt/sheng1.jpg)");
		  $("#nva3").css("background","url(img/qt/shi.jpg)");
		  $("#nva2").removeClass("default").addClass("button");
		  $("#nva1").removeClass("default").addClass("button");
		  $("#guo").css("display","none");
		  $("#sheng").css("display","none");
		  $("#shi").css("display","");
		  type=3;
		  initData();
	  }
}
function initData(){
	$("#zslist").html("");
	var curpage=1;
	var tpage=1;
		IndexDwr.GetTongGaoByPage(type,currentpage,function(data){
			if(type==1){
				currentpage=data.pageNo;
				totalpage=data.totalPages==0?1:data.totalPages;
			}else if(type==2){
				currentpage1=data.pageNo;
				totalpage1=data.totalPages==0?1:data.totalPages;
			}else if(type==3){
				currentpage2=data.pageNo;
				totalpage2=data.totalPages==0?1:data.totalPages;
			}
			curpage=data.pageNo;
			tpage=data.totalPages==0?1:data.totalPages;
			var trs="";
			for(var i=0;i<data.notices.length;i++){
				   trs=trs+template.replace("#Title#",data.notices[i].title)
				                  .replace("#ID#",data.notices[i].id);
				   if(data.notices[i].type==2){
					   trs=trs.replace("#IMG#", '<img alt="" style="border:0px;margin-left:10px;" src="img/gl/format/9.gif"/>')
				   }else{
					   trs=trs.replace("#IMG#","");
				   }
				   if(data.notices[i].isnew){
					   trs=trs.replace("#IMGNew#",'<img class="newimg" alt="" src="img/qt/new.jpg">');
				   }else{
					   trs=trs.replace("#IMGNew#","");
				   }
			   }
			$("#zslist").append(trs);
			$("#pager").css("display","");
			createPager(tpage,curpage,"pager",5);
		});
}
function ChangePage(num){
	if(type==1){
		currentpage=num;
	}else if(type==2){
		currentpage1=num;
	}else if(type==3){
		currentpage2=num;
	}
	initData();
}
var template='<tr>'+
	         '     <td class="ztitle">'+
	         '       <span class="ztle"><a href="tgdetail.do?nid=#ID#" target="_blank">#Title#</a></span>'+
	         '        #IMG#'+
	         '        #IMGNew#'+
	         '     </td>'+
	         '   </tr>';
